function UMessage() {
	var _message = null;
	var self = this;
	
	this.init = function() {
		_message = [];
		_message['title'] = '';
		_message['description'] = '';
		_message['characters'] = 'Characters';
		_message['selected'] = 'Selected';
		_message['taxa'] = 'Taxa';
		_message['matched'] = 'Matched';
	}
	
	this.onLoadMessageReady = function(result) {
		if ( !result ) {
			return;
		}
		for (var i=0; i<result.length; i++) {
			var r = result[i];
	//		alert(r.k +': ' +  r.v);
			_message[r.k] = r.v;
		}
		
		var lang = self.get('lang');
		if ( lang == 'cn' ) {
			_message['characters'] = '特征';
			_message['selected'] = '已使用的特征';
			_message['taxa'] = '分类单位';
			_message['matched'] = '已找到的分类单位';
		}
	}
	
	this.get = function(key, defaultValue) {
		var v = self.getOnly(key);
		if ( !UUtil.isNull(v) ) {
			return v;
		}
		if ( defaultValue ) {
			return defaultValue;
		}
		return null;
	}
	
	this.getOnly = function(key) {
		if ( _message ) {
			var v = _message[key];
			if ( !UUtil.isNull(v) ) {
				return v;
			}
		}
	}		
	
	this.getCharacterState = function(character, index, states) {
		if ( !states ) {
			return '';
		}
		var i = index - 1;
		var v = self.getOnly('c' + character.id + '_' + i);
		if ( !UUtil.isNull(v)) {
			return v;
		}
		if ( i < 0 || i >= states.length) {
			return '';
		}
		return states[i];
	}		
}

UMessage.getInstance = function() {
	if ( UMessage._instance == null ) {
		UMessage._instance = new UMessage();
		UMessage._instance.init();
	}
	return UMessage._instance;
};
